//
//  ViewController.swift
//  SnapKitDemo
//
//  Created by 李煜 on 2023/3/27.
//

import SnapKit//SnapKit (5.6.0)
import UIKit

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .red
    }
  
    //frame方式设置安全区域
    override func viewSafeAreaInsetsDidChange() {
        super.viewSafeAreaInsetsDidChange()
        debugPrint("viewSafeAreaInsetsDidChange")
        
        if #available(iOS 11.0, *) {
            let yellow = UIView()
            yellow.backgroundColor = .yellow
            yellow.frame = CGRect.init(x: self.view.safeAreaInsets.left, y: self.view.safeAreaInsets.top, width: self.view.frame.size.width, height: self.view.frame.size.height - self.view.safeAreaInsets.top - self.view.safeAreaInsets.bottom)
            view.addSubview(yellow)
            
            debugPrint("view:" ,view.safeAreaInsets)
            debugPrint("yellow:" ,yellow.safeAreaInsets)
        } else {
            // Fallback on earlier versions
        }
    }
    
  
}

